<?php
/**
 * 菜单规则模型
 */
namespace app\common\model;

// 引入框架内置类
use think\facade\Request;




class MembershipCard extends Base
{
    protected $name = 'membership_card';
    protected $pk = 'card_id';
    /*public function __construct(){
　　　　$this->interests();
        $this->packageCard();
        $this->summarys();
　　}*/
    public function interests(){
        return $this->hasMany(MembershipInterests::class,"card_key_id");
    }
    public function packageCard(){
        return $this->hasMany(Card::class,"card_id");
    }
    /*public function summarys(){
        
        return  $this->hasOne(Summary::class,"card_id")->bind(['count']);
        
        
        
    }*/
    

    public function comm() {
        $data = $this->belongsTo(MembershipRecords::class,'record_id');
        return $data;
    }
    public function commInterests() {
        return $this->hasMany(MembershipInterests::class,'card_key_id');
    }




    public static function getAll(){
        $list = self::with(["summarys"])
        //->where('type',1)
            ->select()
            ->toArray();

            
        return $list;
    }

    

    // 获取父ID选项信息
    /*public static function getList($order = ['id' => 'desc'])//$order = ['weigh', 'id' => 'desc']
    {
        $list = self::order($order)
            ->select()
            ->toArray();
        
        return $list;
    }
    public static function onAfterWrite($user) {
    	\think\facade\Cache::delete('__menu__');
    }
    public function getTitleAttr($value, $data)
    {
    	return lang($value);
    }*/
}